package com.ruoyi.web.controller.cs;

import java.util.List;
import java.util.Map;

import com.ruoyi.common.core.controller.BasicsController;
import com.ruoyi.common.core.domain.Response;
import com.ruoyi.common.core.page.ResponsePageInfo;
import com.ruoyi.cs.domain.ZBTParamVo;
import com.ruoyi.cs.domain.vo.LuckyTGoodsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.aspectj.weaver.loadtime.Aj;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cs.domain.TGoodsPool;
import com.ruoyi.cs.service.ITGoodsPoolService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 饰品池信息Controller
 * 
 * @author ruoyi
 * @date 2021-05-25
 */
@Api(tags = {"饰品池信息"})
@RestController
@RequestMapping("/cs/pool")
public class TGoodsPoolController extends BasicsController
{
    private static final Logger log = LoggerFactory.getLogger(TGoodsPoolController.class);
    @Autowired
    private ITGoodsPoolService tGoodsPoolService;

    /**
     * 查询饰品池信息列表
     */
    @ApiOperation("查询饰品池信息列表")
    @PreAuthorize("@ss.hasPermi('cs:pool:list')")
    @RequestMapping(name="查询饰品池信息列表",value="list",method = RequestMethod.POST)
    public ResponsePageInfo<TGoodsPool> list(@RequestBody TGoodsPool tGoodsPool)
    {
        startPage(tGoodsPool.getPageNum(),tGoodsPool.getPageSize());
        tGoodsPool.setDelFlag("0");
        List<TGoodsPool> list = tGoodsPoolService.selectTGoodsPoolList(tGoodsPool);
        return toResponsePageInfo(list);
    }

    /**
     * 获取饰品池信息详细信息
     */
    @ApiOperation("获取饰品池信息详细信息")
    @PreAuthorize("@ss.hasPermi('cs:pool:query')")
    @RequestMapping(name="获取饰品池信息详细信息",value="getInfo",method = RequestMethod.GET)

    public Response<TGoodsPool> getInfo(String goodsId)
    {
        return Response.success(tGoodsPoolService.selectTGoodsPoolById(goodsId));
    }

    /**
     * 新增饰品池信息
     */
    @ApiOperation("新增饰品池信息")
    @PreAuthorize("@ss.hasPermi('cs:pool:add')")
    @Log(title = "饰品池信息", businessType = BusinessType.INSERT)
    @RequestMapping(name="新增饰品池信息",value="add",method = RequestMethod.POST)
    public Response<Integer> add(@RequestBody TGoodsPool tGoodsPool)
    {
        return toResponse(tGoodsPoolService.insertTGoodsPool(tGoodsPool));
    }

    /**
     * 修改饰品池信息
     */
    @ApiOperation("修改饰品池信息")
    @PreAuthorize("@ss.hasPermi('cs:pool:edit')")
    @Log(title = "饰品池信息", businessType = BusinessType.UPDATE)
    @RequestMapping(name="修改饰品池信息",value="edit",method = RequestMethod.POST)
    public Response<Integer> edit(@RequestBody TGoodsPool tGoodsPool)
    {
        return toResponse(tGoodsPoolService.updateTGoodsPool(tGoodsPool));
    }

    /**
     * 删除饰品池信息
     */
    @ApiOperation("删除饰品池信息")
    @PreAuthorize("@ss.hasPermi('cs:pool:remove')")
    @Log(title = "饰品池信息", businessType = BusinessType.DELETE)
    @RequestMapping(name="删除饰品池信息",value="remove",method = RequestMethod.GET)
    public Response<Integer> remove(String goodsId)
    {
        return toResponse(tGoodsPoolService.deleteTGoodsPoolById(goodsId));
    }


    /**
     * 饰品下拉框列表
     */
    @ApiOperation("饰品下拉框列表")
    @PreAuthorize("@ss.hasPermi('cs:pool:goodsPoolInfoList')")
    @RequestMapping(name="饰品下拉框列表",value="goodsPoolInfoList", method = RequestMethod.GET)
    public Response<List<Map>> goodsPoolInfoList(String goodsName)
    {
        return Response.success( tGoodsPoolService.goodsPoolInfoList(goodsName));
    }


    /**
     * 更新饰品池信息
     */
    @ApiOperation("更新饰品池信息")
    @PreAuthorize("@ss.hasPermi('cs:pool:updateGoodsPool')")
    @RequestMapping(name="更新饰品池信息",value="updateGoodsPool", method = RequestMethod.POST)
    @Log(title = "饰品池信息", businessType = BusinessType.UPDATE)
    public Response<String> updateGoodsPool(@RequestBody ZBTParamVo zbtParamVo)
    {
        log.info("获取到的参数名称：{}",zbtParamVo == null ? null : zbtParamVo.getKeyword());
        return tGoodsPoolService.updateGoodsPoolYY(zbtParamVo == null ? null : zbtParamVo.getKeyword());
    }

    /**
     * 更新饰品池价格
     */
    @ApiOperation("更新饰品池价格")
    @PreAuthorize("@ss.hasPermi('cs:pool:updateGoodsPoolPrice')")
    @RequestMapping(name="更新饰品池价格",value="updateGoodsPoolPrice", method = RequestMethod.GET)
    @Log(title = "饰品池信息", businessType = BusinessType.UPDATE)
    public Response updateGoodsPoolPrice()
    {
        return tGoodsPoolService.updateGoodsPoolPrice();
    }

    /**
     * 全量更新饰品价格
     */
    @ApiOperation("全量更新饰品价格")
    @PreAuthorize("@ss.hasPermi('cs:pool:completeUpdateGoodsPrice')")
    @RequestMapping(name="全量更新饰品价格",value="completeUpdateGoodsPrice", method = RequestMethod.POST)
    @Log(title = "饰品池信息", businessType = BusinessType.UPDATE)
    public Response completeUpdateGoodsPrice()
    {
        return tGoodsPoolService.completeUpdateGoodsPrice();
    }
}
